<template>
	<view style="display: flex;height:100%">
		<view v-for="(item,index) in tempFiles" :key="item.attachId">
			<img class="img" :src="item.src" alt="" srcset="" @click="previewImg(index)">
		</view>
		<u-empty v-if="tempFiles.length == 0" :text="description" class="u-empty"></u-empty>

	</view>
</template>

<script>
	import {
		getAttachList
	} from "@/api/dums/am/attach";
	import {
		baseUrl
	} from "@/config";
	export default {
		data() {
			return {
				tempFiles: [],
				description:'暂无图片'
			}
		},
		onLoad(options) {
			getAttachList({
				mianId: options.id,
				bussType: "td_comp_maintain_week_plan",
			}).then(res => {
				this.tempFiles = res.rows
				this.tempFiles.map(item => {
					item.src = baseUrl + '/file/' + item.fileUrl
				})
			})
		},
		methods: {
			previewImg(index) {
				// console.log(this.tempFiles);
				// 过滤
				console.log(this.tempFiles)
				let imgUrl = this.tempFiles.map(item => item.src)
				// console.log(imgUrl);
				uni.previewImage({
					current: index, //点击的索引值
					urls: imgUrl,
				})
			},
		}
	}
</script>

<style scoped>
	.img {
		width: 200rpx;
		height: 200rpx;
		object-fit: cover;
		margin: 20rpx 20rpx;
	}
	.u-empty{
		width: 100%;
		height: 100%;
		text-align: center;
		display: flex;
		align-items: center;
		margin-top: 150rpx !important;
	}
</style>